Accept the "expand" attribute and set a flag in the node if it is set to
authorMatthias Clasen <mclasen@redhat.com>
Tue, 8 Feb 2005 15:54:09 +0000 (15:54 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Tue, 8 Feb 2005 15:54:09 +0000 (15:54 +0000)
2005-02-08  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkuimanager.c (start_element_handler): Accept
the "expand" attribute and set a flag in the node if it
is set to "true".
(update_node): If the expand flag is set, make separator
toolitems non-drawn and expanding.  (#166489, Christian Persch)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
docs/reference/ChangeLog
docs/reference/gtk/tmpl/gtkuimanager.sgml
gtk/gtkuimanager.c

index 7d989873dac65968929d029361c84734f5f0c3b4..f7639c6057763f8aca758074b651747b6108105e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-02-08  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkuimanager.c (start_element_handler): Accept 
+       the "expand" attribute and set a flag in the node if it
+       is set to "true".
+       (update_node): If the expand flag is set, make separator
+       toolitems non-drawn and expanding.  (#166489, Christian Persch)
+
+
 2005-02-05  Hans Breuer  <hans@breuer.org>
 
        * gdk/makefile.msc gdk/win32/makefile.msc gtk/makefile.msc.in :
index 7d989873dac65968929d029361c84734f5f0c3b4..f7639c6057763f8aca758074b651747b6108105e 100644 (file)
@@ -1,3 +1,12 @@
+2005-02-08  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkuimanager.c (start_element_handler): Accept 
+       the "expand" attribute and set a flag in the node if it
+       is set to "true".
+       (update_node): If the expand flag is set, make separator
+       toolitems non-drawn and expanding.  (#166489, Christian Persch)
+
+
 2005-02-05  Hans Breuer  <hans@breuer.org>
 
        * gdk/makefile.msc gdk/win32/makefile.msc gtk/makefile.msc.in :
index 7d989873dac65968929d029361c84734f5f0c3b4..f7639c6057763f8aca758074b651747b6108105e 100644 (file)
@@ -1,3 +1,12 @@
+2005-02-08  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkuimanager.c (start_element_handler): Accept 
+       the "expand" attribute and set a flag in the node if it
+       is set to "true".
+       (update_node): If the expand flag is set, make separator
+       toolitems non-drawn and expanding.  (#166489, Christian Persch)
+
+
 2005-02-05  Hans Breuer  <hans@breuer.org>
 
        * gdk/makefile.msc gdk/win32/makefile.msc gtk/makefile.msc.in :
index 56308930cac9da093b938046a8db8972f30e4b97..ae018f88f772bd1b74c6a228479fcb2fb992f6be 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-08  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/tmpl/gtkuimanager.sgml: Mention the expanding
+       toolbar separators.
+
 2005-02-03  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtk-sections.txt: Add gtk_stock_set_translate_func.
index 9f82abf6d93c9df555e188827efd67dee8a5015a..cda5c00fbadfb7e9f7d1d559e923ffe90ceedf18 100644 (file)
@@ -25,27 +25,28 @@ roughly described by the following DTD.
 &lt;!ELEMENT toolitem     EMPTY &gt;
 &lt;!ELEMENT separator    EMPTY &gt;
 &lt;!ELEMENT accelerator  EMPTY &gt;
-&lt;!ATTLIST menubar      name               &num;IMPLIED 
-                       action             &num;IMPLIED &gt;
-&lt;!ATTLIST toolbar      name               &num;IMPLIED 
-                       action             &num;IMPLIED &gt;
-&lt;!ATTLIST popup        name               &num;IMPLIED 
-                       action             &num;IMPLIED &gt;
-&lt;!ATTLIST placeholder  name               &num;IMPLIED
-                       action             &num;IMPLIED &gt;
-&lt;!ATTLIST separator    name               &num;IMPLIED
-                       action             &num;IMPLIED &gt;
-&lt;!ATTLIST menu         name               &num;IMPLIED
-                       action             &num;REQUIRED
-                       position (top|bot) &num;IMPLIED &gt;
-&lt;!ATTLIST menuitem     name               &num;IMPLIED
-                       action             &num;REQUIRED
-                       position (top|bot) &num;IMPLIED &gt;
-&lt;!ATTLIST toolitem     name               &num;IMPLIED
-                       action             &num;REQUIRED
-                       position (top|bot) &num;IMPLIED &gt;
-&lt;!ATTLIST accelerator  name               &num;IMPLIED
-                       action             &num;REQUIRED &gt;
+&lt;!ATTLIST menubar      name                  &num;IMPLIED 
+                       action                &num;IMPLIED &gt;
+&lt;!ATTLIST toolbar      name                  &num;IMPLIED 
+                       action                &num;IMPLIED &gt;
+&lt;!ATTLIST popup        name                  &num;IMPLIED 
+                       action                &num;IMPLIED &gt;
+&lt;!ATTLIST placeholder  name                  &num;IMPLIED
+                       action                &num;IMPLIED &gt;
+&lt;!ATTLIST separator    name                  &num;IMPLIED
+                       action                &num;IMPLIED
+                       expand   (true|false) &num;IMPLIED &gt;
+&lt;!ATTLIST menu         name                  &num;IMPLIED
+                       action                &num;REQUIRED
+                       position (top|bot)    &num;IMPLIED &gt;
+&lt;!ATTLIST menuitem     name                  &num;IMPLIED
+                       action                &num;REQUIRED
+                       position (top|bot)    &num;IMPLIED &gt;
+&lt;!ATTLIST toolitem     name                  &num;IMPLIED
+                       action                &num;REQUIRED
+                       position (top|bot)    &num;IMPLIED &gt;
+&lt;!ATTLIST accelerator  name                  &num;IMPLIED
+                       action                &num;REQUIRED &gt;
 </programlisting>
 There are some additional restrictions beyond those specified in the
 DTD, e.g. every toolitem must have a toolbar in its anchestry and
@@ -166,6 +167,12 @@ is a useful feature, since the merging of UI elements from multiple sources
 can make it hard or impossible to determine in advance whether a separator 
 will end up in such an unfortunate position.
 </para>
+
+<para>
+For separators in toolbars, you can set <literal>expand="true"</literal> to
+turn them from a small, visible separator to an expanding, invisible one.
+Toolitems following an expanding separator are effectively right-aligned.
+</para>
 </refsect2>
 <refsect2>
 <title>Empty Menus</title>
index 439cfc8ec32ce6a97191cbf32f340375949f75cd..a2dc4ac61191d72be8385ff06ebc01ce68495e02 100644 (file)
@@ -76,6 +76,7 @@ struct _Node {
   GList *uifiles;
 
   guint dirty : 1;
+  guint expand : 1;  /* used for separators */
 };
 
 #define GTK_UI_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_UI_MANAGER, GtkUIManagerPrivate))
@@ -1102,6 +1103,7 @@ start_element_handler (GMarkupParseContext *context,
   const gchar *action;
   GQuark action_quark;
   gboolean top;
+  gboolean expand;
   
   gboolean raise_error = TRUE;
 
@@ -1125,6 +1127,10 @@ start_element_handler (GMarkupParseContext *context,
        {
          top = !strcmp (attribute_values[i], "top");
        }
+      else if (!strcmp (attribute_names[i], "expand"))
+       {
+         expand = !strcmp (attribute_values[i], "true");
+       }
       else
        {
          gint line_number, char_number;
@@ -1282,6 +1288,8 @@ start_element_handler (GMarkupParseContext *context,
                                 NODE_TYPE_SEPARATOR,
                                 TRUE, top);
 
+         NODE_INFO (node)->expand = expand;
+
          if (NODE_INFO (node)->action_name == 0)
            NODE_INFO (node)->action_name = action_quark;
 
@@ -2467,6 +2475,7 @@ update_node (GtkUIManager *self,
        {
          GtkWidget *toolbar;
          gint pos;
+         gint separator_mode;
          
          if (GTK_IS_SEPARATOR_TOOL_ITEM (info->proxy))
            {
@@ -2484,9 +2493,18 @@ update_node (GtkUIManager *self,
              g_object_ref (info->proxy);
              gtk_object_sink (GTK_OBJECT (info->proxy));
              gtk_widget_set_no_show_all (info->proxy, TRUE);
+             if (info->expand)
+               {
+                 gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), TRUE);
+                 gtk_separator_tool_item_set_draw (item, FALSE);
+                 separator_mode = SEPARATOR_MODE_VISIBLE;
+               }
+               else
+                 separator_mode = SEPARATOR_MODE_SMART;
+
              g_object_set_data (G_OBJECT (info->proxy),
                                 "gtk-separator-mode",
-                                GINT_TO_POINTER (SEPARATOR_MODE_SMART));
+                                GINT_TO_POINTER (separator_mode));
              gtk_widget_show (info->proxy);
            }
        }